<span class="glyphicon glyphicon-map-marker" aria-hidden="true">
    <span>系统</span> /
    <span>资讯中心</span> /
    <span>新闻类型列表</span>
</span>
<div style="width: 100%;margin-top: 20px;">
    <a name="add" title="添加" class="ncap-btn-big ncap-btn-green"
    style="background-color: #00a0e9;" href="{:url('admin/NewsType/Add')}">添加</a>
    <div class="table-responsive" style="border:0px solid #fff;">
        <table class="table"  border="1" width="100%" cellpadding="0" cellspacing="0" style="margin: 10px 0px;">
            <tr>
                <td width="4%"  style="height: 35px;vertical-align: middle;">
                    <input type="checkbox" id="ids" onclick="getCheckbox()" />
                </td>
                <td width="5%" style="vertical-align: middle;">ID</td>
                <td width="10%" style="vertical-align: middle;">新闻类型</td>
                <td width="15%" style="vertical-align: middle;">logo</td>
                <td width="18%" style="vertical-align: middle;">发布时间</td>
                <td width="18%" style="vertical-align: middle;">更新时间</td>
                <td width="8%" style="vertical-align: middle;">排序顺序</td>
                <td width="" style="vertical-align: middle;">操作</td>
            </tr>
            {volist name="list" id="vo"}
            <tr>
                <td style="vertical-align: middle;">
                    <input type="checkbox" name="ids[]" onclick="getCheckboxByIds({$vo.id})" id="ids-{$vo.id}" value="{$vo.id}" />
                </td>
                <td style="vertical-align: middle;">{$vo.id}</td>
                <td style="vertical-align: middle;">{$vo.title}</td>
                <td style="vertical-align: middle;">
                    {if condition="$vo.uploadLogo"}
                    <img src="__IMG__{$vo.uploadLogo.path}" style="max-width: 200px;max-height: 40px;"
                         data-target="#modal" data-toggle="modal"
                         onclick="getPicture('{$vo.logo}')" />
                    {/if}
                </td>
                <td style="vertical-align: middle;">{$vo.create_time}</td>
                <td style="vertical-align: middle;">{$vo.update_time}</td>
                <td style="vertical-align: middle;">
                    <input type="number" step="1" min="0" value="{$vo.sort}" id="sort-{$vo.id}" name="sort-{$vo.id}"
                           class="form-control" onblur="getSort({$vo.id})"  />
                </td>
                <td style="vertical-align: middle;">
                    <a href="{:url('Admin/NewsType/Edit',array('id' => $vo.id))}" class="ncap-btn-big ncap-btn-green"
                       style="background-color: #00a0e9;">编辑</a>
                    {php} if($vo['id'] > 1) { {/php}
                    <a href="javascript:NewsTypeDelete('{$vo.id}')" class="ncap-btn-big ncap-btn-green"
                    style="background-color: #ff0055;">删除</a>
                    {php} } {/php}
                </td>
            </tr>
            {/volist}
        </table>
        <div class="pagination">
            {$list -> render();}
        </div>
    </div>
</div>
<script type="text/javascript">
    //排序
    function getSort(id) {
        var sort = $("input[id='sort-"+id+"']").val();
        var json = {id:id,sort:sort};
        $.ajax({
            type:"post",
            url:"{:url('Admin/NewsType/Sort')}",
            data:json,
            success:function (res) {
                if(res != "排序成功"){
                    layer.msg(res);
                }
                if(res == "请重新登录"){
                    setTimeout("location_href()",1500);
                }
            }
        });
    }
    //删除
    function NewsTypeDelete(id) {
        layer.confirm('请确认是否删除', {
            icon: 3,btn: ['确认','取消'] //按钮
        }, function(){
            $.ajax({
                type:"post",
                url:"{:url('admin/NewsType/delete')}",
                data:{
                    "id":id
                },
                success:function (res) {
                    title(res);
                    setTimeout('location_href()',1500);
                }
            });
        }, function () {
            title('取消操作');
        });
    }
</script>